<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-3.3.1.js"></script>
<script type="text/javascript">
	//页面
	$.post("GetBooksByPageServlet",function(data,status) {
		console.log(data);
	})
</script>
<script>
	
	
</script>
</head>
<body>
	<button id="btn">第二页</button>
	<form action="SetQueryTerm" method="post">
		<input type="text" id="queryTerm">
		<input type="button" value="查询" id="butt">
	</form>
	
	

	
	<input type="button" value="insertOrdertest" id="test">
	<input type="button" value="insertOrdertest2" id="test3">
	<input type="button" value="queryOrdertest" id="test2">
	<input type="button" value="queryOrder" id="test4">
	
	
	<form action="../UserServlet" enctype="multipart/form-data" id="form1" method="post" >
		<input type="file" id="f">
		<input type="text" id="username">
		<input type="text" id="password">
		<input type="submit" value="qweasd">
	</form>
</body>
<script>
$("#form1").submit(function(e){
	console.log("aa");
	e.preventDefault();
	var formFile = new FormData();
	var fileObj = document.getElementById("f").files[0];
	formFile.append("username",$("#username").val());  
	formFile.append("password",$("#password").val());  
    formFile.append("file", fileObj); //加入文件对象
    var data = formFile;
    
	$.ajax({
        url: "../UserServlet",
        data:data,
        type: "Post",
        dataType: "json",
        cache: false,//上传文件无需缓存
        processData: false,//用于对data参数进行序列化处理 这里必须false
        contentType: false, //必须
        success: function (result) {
            alert("上传完成!");
        },
    })
})

	$("#test4").click(
		function(){
			$.post("GetOrderInfoByOrderIdServelt",{orderId:2},function(data,status){
				console.log(data);
			})
		}
	)

	$("#test").click(
		function(){
			$.post("InsertOrderServlet",{bookId:2,count:2},function(data,status){
				console.log(data);
			})
		}
	)
	$("#test3").click(
		function(){
			$.post("InsertOrderServlet",{bookId:1,count:1},function(data,status){
				console.log(data);
			})
		}
	)
	
	$("#test2").click(
		function(){
			$.post("GetOrderInfoServlet",function(data,status){
				console.log(data);
			})
		}
	)

	$("#btn").click(
		function(){
			$.post("SetCurrentPageServlet",{currentPage:2},function(data,status) {
			})
			$.post("GetBooksByPageServlet",function(data,status) {
			console.log(data);
			})
		}
		
	)
	$("#butt").click(
			function(){
				$.post("SetQueryTermServlet",{queryTerm:$("#queryTerm").val()})
				$.post("GetBooksByPageServlet",{currentPage:1},function(data,status) {
					console.log(data);
				})
			}
	)
	
	
	
</script>
</html>